package com.ruoyi.weiriya.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.ruoyi.weiriya.domain.WMessage;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 平台消息推送管理Mapper接口
 * 
 * @author lynn
 * @date 2023-08-01
 */
public interface WMessageMapper extends BaseMapper<WMessage>
{

    @Select("SELECT msg.*, m.nick_name as member_name, a.name as area_name,u.nick_name as reply_user_name " +
            "FROM w_message msg " +
            "LEFT JOIN w_member m on m.id = msg.member_id " +
            "LEFT JOIN sys_user u on u.user_id = msg.reply_user_id " +
            "LEFT JOIN w_area a on a.id = msg.area_id ${ew.customSqlSegment}")
    List<WMessage> getList(@Param(Constants.WRAPPER) QueryWrapper<WMessage> queryWrapper);

    @Select("SELECT msg.*, m.nick_name as member_name, a.name as area_name,u.nick_name as reply_user_name " +
            "FROM w_message msg " +
            "LEFT JOIN w_member m on m.id = msg.member_id " +
            "LEFT JOIN sys_user u on u.user_id = msg.reply_user_id " +
            "LEFT JOIN w_area a on a.id = msg.area_id " +
            "WHERE msg.id = #{id}")
    WMessage getWMessageById(String id);
}
